package com.jspm.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jspm.dao.ZixuanbankuaiDao;
import com.jspm.entity.ZixuanbankuaiEntity;
import com.jspm.entity.view.ZixuanbankuaiView;
import com.jspm.entity.vo.ZixuanbankuaiVO;
import com.jspm.service.ZixuanbankuaiService;
import com.jspm.utils.PageUtils;
import com.jspm.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("zixuanbankuaiService")
//@Transactional // 添加事务注解
public class ZixuanbankuaiServiceImpl extends ServiceImpl<ZixuanbankuaiDao, ZixuanbankuaiEntity> implements ZixuanbankuaiService {

	@Autowired
	private ZixuanbankuaiDao zixuanbankuaiDao;

    @Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ZixuanbankuaiEntity> page = this.selectPage(
                new Query<ZixuanbankuaiEntity>(params).getPage(),
                new EntityWrapper<ZixuanbankuaiEntity>()
        );
        return new PageUtils(page);
    }
    
    @Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public PageUtils queryPage(Map<String, Object> params, Wrapper<ZixuanbankuaiEntity> wrapper) {
		  Page<ZixuanbankuaiView> page =new Query<ZixuanbankuaiView>(params).getPage();
	        page.setRecords(zixuanbankuaiDao.selectListView(page,wrapper));
	    	PageUtils pageUtil = new PageUtils(page);
	    	return pageUtil;
 	}
    
    @Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public List<ZixuanbankuaiVO> selectListVO(Wrapper<ZixuanbankuaiEntity> wrapper) {
 		return zixuanbankuaiDao.selectListVO(wrapper);
	}
	
	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public ZixuanbankuaiVO selectVO(Wrapper<ZixuanbankuaiEntity> wrapper) {
 		return zixuanbankuaiDao.selectVO(wrapper);
	}
	
	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public List<ZixuanbankuaiView> selectListView(Wrapper<ZixuanbankuaiEntity> wrapper) {
		return zixuanbankuaiDao.selectListView(wrapper);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true) // 只读事务
	public ZixuanbankuaiView selectView(Wrapper<ZixuanbankuaiEntity> wrapper) {
		return zixuanbankuaiDao.selectView(wrapper);
	}


}
